package com.mtbu.bean;
import java.text.SimpleDateFormat;

import org.json.JSONObject;

import com.mtbu.bean.base.StatsPlaystartBase;
public final class StatsPlaystart extends StatsPlaystartBase {
	public String toString(){
		return "[" 
			+ super.getL() + ","
			+ super.getM() + ","
			+ super.getN() + ","
			+ super.getP() + ","
			+ super.getQ() + "]" ;
	}
	
	public String toLogString(){
		return "[" 
			+ super.getL() + ","
			+ super.getM() + ","
			+ super.getN() + ","
			+ super.getP() + ","
			+ super.getQ() + "]" ;
	}
	
	public JSONObject toJSON() throws Exception {
		JSONObject json = new JSONObject();
	    if (super.getA() != 0L) { 
	    	json.put("A", this.getA());
	    } 
	    if (super.getC() != 0L) { 
	    	json.put("C", this.getC());
	    }
	    if (super.getL() != 0L) { 
	    	json.put("L", this.getL());
	    }
	    if (super.getM() != 0L) { 
	    	json.put("M", this.getM());
	    }
	    if (super.getN() != 0L) { 
	    	json.put("N", this.getN());
	    }
	    if (super.getP() != 0L) { 
	    	json.put("P", this.getP());
	    }
	    if (super.getQ() != 0L) { 
	    	json.put("Q", this.getQ());
	    }

	    return json;
	}
	 
	public void fromJSON(JSONObject json) throws Exception {
		if(json==null) return;
		try{
			if(json.get("A") != null){
				this.setA(Long.parseLong(json.get("A")+""));
	        }
			else{
				this.setA(-1);
			}
		}
	    catch(Exception ex){
	    	this.setA(-1);
	    }
	    try{
	        if(json.get("C") != null){
	            this.setC(Long.parseLong(json.get("C")+""));
	        }
	        else{
	        	this.setC(-1);
	        }
	    }catch(Exception ex){
	    	this.setC(-1);
	    }
	    try{
	        if(json.get("L") != null){
	            this.setL(Long.parseLong(json.get("L")+""));
	        }
	        else{
	        	this.setL(-1);
	        }
	    }catch(Exception ex){
	    	this.setL(-1);
	    }
	    try{
	        if(json.get("M") != null){
	            this.setM(Long.parseLong(json.get("M")+""));
	        }
	        else{
	        	this.setM(-1);
	        }
	    }catch(Exception ex){
	    	this.setM(-1);
	    }
	    try{
	        if(json.get("N") != null){
	            this.setN(Long.parseLong(json.get("N")+""));
	        }
	        else{
	        	this.setN(-1);
	        }
	    }catch(Exception ex){
	    	this.setN(-1);
	    }
	    try{
	        if(json.get("P") != null){
	            this.setP(Long.parseLong(json.get("P")+""));
	        }
	        else{
	        	this.setP(-1);
	        }
	    }catch(Exception ex){
	    	this.setP(-1);
	    }
	    try{
	        if(json.get("Q") != null){
	            this.setQ(Long.parseLong(json.get("Q")+""));
	        }
	        else{
	        	this.setQ(-1);
	        }
	    }catch(Exception ex){
	    	this.setQ(-1);
	    }
	}
}
